<%@ page contentType="text/html; charset=UTF-8" import="javax.naming.*,javax.sql.*,java.sql.*"%>
<%
        if(request.getParameter("size")!=null && request.getParameter("lookupName")!=null){
          Connection conn[] = new Connection[Integer.parseInt(request.getParameter("size").toString())];
          int i=1;
          try {
            for(i=1;i<=Integer.parseInt(request.getParameter("size").toString());i++){
              out.println(i + " start==>"  + new java.util.Date());
              out.print("<br/>");
              Context ctx = new InitialContext();
              Context envContext = (Context) ctx.lookup("java:comp/env/");
              DataSource ds = (DataSource) envContext.lookup(request.getParameter("lookupName"));
              conn[i-1] = ds.getConnection();
              out.println(i + " end==>"  + new java.util.Date());
              out.print("<br/>");
              out.flush();
            }
          } catch (Exception ex) {
            out.print(i);
            out.print("<br/>");
            out.print(ex.toString());
          }
          finally{
            for(i=1;i<=Integer.parseInt(request.getParameter("size").toString());i++){
              try{conn[i-1].close();}catch(Exception e){}
              conn[i-1]=null;
            }
          }
        }
 %>
<html>
<head>
<title>
TestConnPool
</title>
</head>
<body bgcolor="#ffffff">
<form action="TestConnPool_param_loop.jsp" method="POST">
  LookUpName：<input type="text" name="lookupName" size="50" /><br />
  Connection Size：<input type="text" name="size" size="4" value="1"/><br />
  <input type="submit" value="submit" />
</form>
</body>
</html>
